import java.util.ArrayList;
import java.util.Collections;

public enum Deck {
    Instance;

    private static final int MAX_CARD = 52;

    private Deck() {
        Initiate();
    }

    private ArrayList<Card> _cards;

    public void Initiate() {
        _cards = new ArrayList<Card>(MAX_CARD);

        for (int i = 0; i < 13; i++) {
            for (int j = 0; j < 4; j++) {
//                Card card = new Card(i + 1, Suit.valueOf(String.valueOf(j)));
                Card card = new Card(i + 1, Suit.Clover);
                _cards.add(card);
            }
        }

        _index = 0;

        Collections.shuffle(_cards);
    }

    private int _index;

    public Card fetch(){
        if (_index == MAX_CARD)
            Initiate();

        return _cards.get(_index++);
    }

}
